<?php
        require_once('paths.inc');
        require_once('page.inc');
        require_once('utils.inc');
        require_once(INCLUDE_PATH.'constants.inc');
        
        session_start();
        select_language();
        
        if (isset($_GET['index'])) $index = $_GET['index'];
        
        $raspuns_final_id1 = $_GET['raspuns_final_id1'];
        $raspuns_final_id2 = $_GET['raspuns_final_id2'];
		
        $from = $_GET['from'];
        
        if (isset($index) && !empty($index)) {			                 
			require_once(DB_PATH.'db.inc');    
			$db = db_connect();
            $firma = Firma::queryLoadById($db, $index, $_SESSION['user_logat']->id_client);
			$text = LANG_Update_firma;
			$opt = "update";	
		}
		else {                                     
			$text = LANG_Add_Firm; 
			$opt = "insert";
			$cont = new Firma($_SESSION['user_logat']->id_client);
		}
        
		if (!isset($index)) $index = -1;
        
        $help_text = LANG_EXTRA_MODAL_EDIT_FIRMA_FROM_COMANDA;
        if ($opt == "insert")
            $help_text = LANG_EXTRA_MODAL_ADD_FIRMA_FROM_COMANDA;
		
		echo "<div align=\"center\">";
			echo '<table align="center" cellpadding="3" cellspacing="0" border="0" id="wrapper2">';
				echo "<thead>";
					echo "<tr>";
						echo "<th colspan=\"2\">";
							echo $text;
						echo "</th>";
					echo "</tr>";				
				echo "</thead>";
				echo '<tr class="capTabel">';
                    echo '<td id="td_nume_firma_modal" align="right"><b>' . LANG_NUME_FIRMA . CT_OBLIGATORIU . '</b></td>';
                    echo '<td align="left"><input type="text" value="' . $firma->nume . '" name="nume_firma_modal" id="nume_firma_modal" size="' . CT_MODAL_ADD_FIRMA_FROM_COMANDA . '" />';
                echo '</tr>';
				
				echo '<tr class="capTabel">';
					echo '<td id="td_tel_fix_modal" align="right"><b>'.LANG_TEL_FIX .'</b></td>';
					echo '<td align="left"><input type="text" value="' . $firma->tel_fix . '" name="tel_fix_modal" id="tel_fix_modal" size="' . CT_MODAL_ADD_FIRMA_FROM_COMANDA . '" />';
				echo '</tr>';
				echo '<tr class="capTabel">';
					echo '<td id="td_tel_mobil_modal" align="right"><b>'.LANG_TEL_MOBIL . '</b></td>';
					echo '<td align="left"><input type="text" value="' . $firma->tel_mobil . '" name="tel_mobil_modal" id="tel_mobil_modal" size="' . CT_MODAL_ADD_FIRMA_FROM_COMANDA . '" />';
				echo '</tr>';
				echo '<tr class="capTabel">';
					echo '<td id="td_tel_fax_modal" align="right"><b>'.LANG_TEL_FAX . '</b></td>';
					echo '<td align="left"><input type="text" value="' . $firma->tel_fax . '" name="tel_fax_modal" id="tel_fax_modal" size="' . CT_MODAL_ADD_FIRMA_FROM_COMANDA . '" />';
				echo '</tr>';			
				echo '<tr class="capTabel">';
					echo '<td id="td_email_modal" align="right"><b>'.LANG_EMAIL . '</b></td>';
					echo '<td align="left"><input type="text" value="' . $firma->email . '" name="email_modal" id="email_modal" size="' . CT_MODAL_ADD_FIRMA_FROM_COMANDA . '" />';
				echo '</tr>';					
				echo '<tr class="capTabel">';
					echo "<td colspan=\"2\" align=\"center\">";
						echo '<input type="button" name="add_firma_confirm" id="add_firma_confirm" value="' . $text . '"' . "onclick=\"javascript: new_firma_confirm('" . $from . "','" . $opt ."'," . $index . ",'" . $raspuns_final_id1 . "','" . $raspuns_final_id2 . "');\" />&nbsp;&nbsp;";
                        echo '<input type="button" name="cancel" value="'.LANG_CANCEL.'" onclick="javascript: closeMessage();" />';						
					echo "</td>";
				echo '</tr>';
                echo output_extra_text_modal($help_text, 2);
			echo '</table>';
		echo "</div>";
		flush();
?>